<template>
  <div class="header">
    <div class="large-header" v-if="type == false">
      <img class="img1" src="../assets/imgs/图层1.png" alt="" />
      <ul>
        <li
          :class="[currentIndex === index ? 'current' : '']"
          v-for="(item, index) in list"
          :key="index"
          @click="handleChangeTab(index, item.path)"
        >
          {{ item.title }}
        </li>
      </ul>
      <div class="tel-box">
        <img class="img2" src="../assets/imgs/电话.png" alt="" />
        <p>咨询热线：400-827-1827</p>
      </div>
    </div>
    <div class="iphone-header" v-if="type == true">
      <img
        :class="[show ? 'img-current' : '']"
        @click="clickMenu"
        src="../assets/imgs/菜单.png"
        alt=""
      />
      <ul v-if="show">
        <li
          :class="[currentIndex === index ? 'current' : '']"
          v-for="(item, index) in list"
          :key="index"
          @click="handleChangeTab(index, item.path)"
        >
          {{ item.title }}
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  props: ["currentIndex"],
  data() {
    return {
      type: false,
      show: false,
      list: [
        { title: "首页", key: 1, path: "/" },
        { title: "加盟中心", key: 2, path: "/join" },
        { title: "客户案例", key: 3, path: "/customer" },
        { title: "资源中心", key: 4, path: "/source" },
        { title: "关于我们", key: 5, path: "/about_us" },
      ],
    };
  },

  mounted() {
    let wid = document.body.clientWidth;
    if (wid <= 1024) {
      this.type = true;
    }
  },

  methods: {
    handleChangeTab(index, path) {
      // this.currentIndex = index;
      // console.log(index);
      this.show = !this.show;
      this.$router.push(path);
    },
    clickMenu() {
      this.show = !this.show;
    },
  },
};
</script>

<style scoped>
.large-header ul {
  list-style: none;
  display: flex;
  width: 792px;
  justify-content: space-between;
}
.header {
  /* padding: 0 120px; */
  position: absolute;
  width: 100%;
  z-index: 999;
}
.large-header {
  background: transparent;
  color: #000;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 20px 50px;
  /* height: 260px; */
}
.tel-box {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.large-header li {
  padding: 10px 20px;
  text-align: center;
  cursor: pointer;
  font-size: 16px;
}
.current {
  background: #4372c3;
  border-radius: 3px;
  color: #fff !important;
}
.img1 {
  width: 92px;
  height: 70px;
}
.img2 {
  width: 25px;
  height: 26px;
}
.tel-box {
  font-size: 18px;
}
.iphone-header {
  /* background: #011949; */
  color: #fff;
  display: flex;
  align-items: flex-start;
  padding: 20px 50px;
  /* height: 260px; */
}
.iphone-header img {
  width: 164px;
  height: 164px;
  position: relative;
}
.iphone-header ul {
  list-style: none;
  position: absolute;
  top: 200px;
  background: #fff;
  z-index: 999;
  padding: 20px 0;
  border: 2px solid #f1f1f1;
  border-radius: 5px;
}
.iphone-header ul li {
  font-size: 75px;
  color: #000;
  padding: 40px 60px;
  text-align: center;
  border-bottom: 2px solid #c2c0c0;
}
.img-current {
  transform: rotate(90deg);
}
</style>